let utils = data["utils"];
let STUtil = data["STUtil"];
let Node = data["Node"];
let SplayTree = data["SplayTree"];
let isInBbox = data["isInBbox"];
let getBboxOverlap = data["getBboxOverlap"];
let cmp = data["cmp"];
let crossProduct = data["crossProduct"];
let dotProduct = data["dotProduct"];
let compareVectorAngles = data["compareVectorAngles"];
let sineOfAngle = data["sineOfAngle"];
let cosineOfAngle = data["cosineOfAngle"];
let closestPoint = data["closestPoint"];
let horizontalIntersection = data["horizontalIntersection"];
let verticalIntersection = data["verticalIntersection"];
let intersection = data["intersection"];
let perpendicular = data["perpendicular"];
let rounder = data["rounder"];
let geomIn = data["geomIn"];
let geomOut = data["geomOut"];
let operation = data["operation"];
let Segment = data["Segment"];
let SweepEvent = data["SweepEvent"];
let SweepLine = data["SweepLine"];

console.log("12PolygonClipping_segment01_2");


utils.extend(Segment.prototype, { replaceRightSE: function (newRightSE) { this.rightSE = newRightSE, this.rightSE.segment = this, this.rightSE.otherSE = this.leftSE, this.leftSE.otherSE = this.rightSE }, bbox: function () { const y1 = this.leftSE.point.y, y2 = this.rightSE.point.y; return { ll: { x: this.leftSE.point.x, y: y1 < y2 ? y1 : y2 }, ur: { x: this.rightSE.point.x, y: y1 > y2 ? y1 : y2 } } }, vector: function () { return { x: this.rightSE.point.x - this.leftSE.point.x, y: this.rightSE.point.y - this.leftSE.point.y } }, isAnEndpoint: function (pt) { return pt.x === this.leftSE.point.x && pt.y === this.leftSE.point.y || pt.x === this.rightSE.point.x && pt.y === this.rightSE.point.y }, comparePoint: function (point) { if (this.isAnEndpoint(point)) return 0; const lPt = this.leftSE.point, rPt = this.rightSE.point, v = this.vector(); if (lPt.x === rPt.x) return point.x === lPt.x ? 0 : point.x < lPt.x ? 1 : -1; const yDist = (point.y - lPt.y) / v.y, xFromYDist = lPt.x + yDist * v.x; if (point.x === xFromYDist) return 0; const xDist = (point.x - lPt.x) / v.x, yFromXDist = lPt.y + xDist * v.y; return point.y === yFromXDist ? 0 : point.y < yFromXDist ? -1 : 1 }, getIntersection: function (other) { const tBbox = this.bbox(), oBbox = other.bbox(), bboxOverlap = getBboxOverlap(tBbox, oBbox); if (null === bboxOverlap) return null; const tlp = this.leftSE.point, trp = this.rightSE.point, olp = other.leftSE.point, orp = other.rightSE.point, touchesOtherLSE = isInBbox(tBbox, olp) && 0 === this.comparePoint(olp), touchesThisLSE = isInBbox(oBbox, tlp) && 0 === other.comparePoint(tlp), touchesOtherRSE = isInBbox(tBbox, orp) && 0 === this.comparePoint(orp), touchesThisRSE = isInBbox(oBbox, trp) && 0 === other.comparePoint(trp); if (touchesThisLSE && touchesOtherLSE) return touchesThisRSE && !touchesOtherRSE ? trp : !touchesThisRSE && touchesOtherRSE ? orp : null; if (touchesThisLSE) return touchesOtherRSE && tlp.x === orp.x && tlp.y === orp.y ? null : tlp; if (touchesOtherLSE) return touchesThisRSE && trp.x === olp.x && trp.y === olp.y ? null : olp; if (touchesThisRSE && touchesOtherRSE) return null; if (touchesThisRSE) return trp; if (touchesOtherRSE) return orp; const pt = intersection(tlp, this.vector(), olp, other.vector()); return null === pt ? null : isInBbox(bboxOverlap, pt) ? rounder.round(pt.x, pt.y) : null } });


return {
  "utils": utils,
  "STUtil": STUtil,
  "Node": Node,
  "SplayTree": SplayTree,
  "isInBbox": isInBbox,
  "getBboxOverlap": getBboxOverlap,
  "cmp": cmp,
  "crossProduct": crossProduct,
  "dotProduct": dotProduct,
  "compareVectorAngles": compareVectorAngles,
  // "length":length,
  "sineOfAngle": sineOfAngle,
  "cosineOfAngle": cosineOfAngle,
  "closestPoint": closestPoint,
  "horizontalIntersection": horizontalIntersection,
  "verticalIntersection": verticalIntersection,
  "intersection": intersection,
  "perpendicular": perpendicular,
  "rounder": rounder,
  "geomIn": geomIn,
  "geomOut": geomOut,
  "operation": operation,
  "Segment": Segment,
  "SweepEvent": SweepEvent,
  "SweepLine": SweepLine
}